package demo1;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-07-07
 * Time: 12:26
 */
public class Test {
    public static void main(String[] args) {
        Student[] students=new Student[3];
        students[0]=new Student("John",17);
        students[1]=new Student("Amy",14);
        students[2]=new Student("Marry",19);

        AgeComparator ageComparator=new AgeComparator();
        NameComparator nameComparator=new NameComparator();

        Arrays.sort(students,ageComparator);
        Arrays.sort(students,nameComparator);

        System.out.println(Arrays.toString(students));


//        Student s1=new Student("abc",12);
//        Student s2=new Student("bcd",15);
//
//        AgeComparator ageComparator=new AgeComparator();
//        NameComparator nameComparator=new NameComparator();

        //最后返回的都是int型的数值
//        int ret1= ageComparator.compare(s1,s2);
//        System.out.println();
//        int ret2= nameComparator.compare(s1,s2);
//        System.out.println();
//
//        System.out.println(ret1+" "+ret2);

    }
}


